import java.util.Arrays;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int x = in.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
        }
        long ret = 0;
        if (x > n) {
            for (int num : nums) {
                ret += num;
            }
        } else {
            Arrays.sort(nums);
            ret += x * nums[n - x];
            for (int i = n - x + 1; i < n; i++) {
                ret += (nums[i] - nums[n - x]);
            }
        }
        System.out.println(ret);
    }
}
